const cloud = require('wx-server-sdk')

cloud.init()

exports.main = async (event) => {
  const id = event.id;

  if (id == null) {
    return {
      code: -1
    };
  }

  const db = cloud.database();

  try {
    await db.collection('cards').doc(id).remove();
    return {
      code: 0
    };
  } catch (e) {
    return {
      code: -2,
      result: e
    }
  }
}
